package dlg.code.strategy;

/***
 * @param <T>
 *     接口加泛型来适应不同的数据类型
 */
public class MySort<T> {

    public void sort(T[] data, MyComparator myComparator){
        for (int i = 1; i < data.length; i++) {
            for (int j = i; j > 0; j--) {
                if(myComparator.compare(data[j], data[j - 1]) < 0){
                    T temp = data[j];
                    data[j] = data[j - 1];
                    data[j - 1] = temp;
                }
            }
        }
    }

}
